#!/usr/bin/env python
#-*-coding:utf8-*-

'''
@author: Seven
@license: GNU GPL v3
@contact: seven.ling0307@gmail.com
'''

import sys
try:
	from hashlib import md5
except:
	from md5 import md5


def sumfile(fobj):
	m = md5()
	while True:
		d = fobj.read(10240)
		if not d:
			break
		m.update(d)
	del(d)
	return m.hexdigest()

def sumstr(string):
	m=md5()
	m.update(string)
	return m.hexdigest()

def md5sum(fname): 
	try:
		f = open(fname, 'rb')
	except:
		return False
	ret = sumfile(f)
	f.close()
	return ret


if __name__ == '__main__':
	for fname in sys.argv[1:]:
		res=md5sum(fname)
		if res == False:
			res=sumstr(fname)
		print '%32s  %s' % (res, fname)
